<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登录注册</title>
    <link rel="stylesheet" href="/stylesheets/myAlert.css">
    <link rel='stylesheet' href='/stylesheets/style.css' />
    <link href="/stylesheets/login.css" rel="stylesheet" type="text/css" />
    <!-- <link rel="stylesheet" href="/bootstrap-3.3.7/dist/css/bootstrap.css"> -->
    <script src="/javascripts/jquery.min.js"></script>
    <script src='/bootstrap-3.3.7/dist/js/bootstrap.min.js'></script>
    <!-- <script src='/javascripts/bootstrapValidator.js'></script> -->
    <script src='/javascripts/myAlert.js'></script>
    <script src='/javascripts/login.js'></script>
  </head>
  <body>
  <div class="main_con">
  	<a href="/"><h1>佛系养生<sup>馆</sup></h1></a>
    <div class="login" style="margin-top:50px;">        
        <div class="header">
            <div class="switch" id="switch"><a class="switch_btn_focus" id="switch_qlogin" href="javascript:void(0);" tabindex="7">快速登录</a>
          <a class="switch_btn" id="switch_login" href="javascript:void(0);" tabindex="8">快速注册</a>
          <div class="switch_bottom" id="switch_bottom" style="position: absolute; width: 64px; left: 0px;"></div>
            </div>
        </div>    
        <div class="web_qr_login" id="web_qr_login" style="display: block; height: 235px;">    
              <!--登录-->
              <div class="web_login" id="web_login">  
                 <div class="login-box">
                    <div class="login_form">
                      <form action="/myHome" name="loginform" accept-charset="utf-8" id="login_form" class="loginForm" method="post">
                        <input type="hidden" name="did" value="0"/>
                        <input type="hidden" name="to" value="log"/>
                        <div class="uinArea" id="uinArea">
                          <label class="input-tips" for="u">佛主帐号：</label>
                          <div class="inputOuter" id="uArea" name="username">
                              <input type="text" id="u" name="name" class="inputstyle"/>
                          </div>
                        </div>
                        <div class="pwdArea" id="pwdArea">
                          <label class="input-tips" for="p" name="password">佛主密码：</label> 
                          <div class="inputOuter" id="pArea">
                            <input type="password" id="p" name="p" class="inputstyle"/>
                          </div>
                        </div>
                     
                        <div style="padding-left:80px;margin-top:20px;" onclick="check_pass()">
                          <span type="" value="登 录" style="width:150px;line-height: 41px;" class="button_blue">登 录</span>
                        </div>
                      </form>
                  </div>
                </div>                   
              </div>    <!--登录end-->
        </div>

      <!--注册-->
        <div class="qlogin" id="qlogin" style="display: none; ">   
          <div class="web_login">
            <form name="form2" id="regUser" accept-charset="utf-8"  action="register" method="post">
                <input type="hidden" name="to" value="reg"/>
                <input type="hidden" name="did" value="0"/>
                <ul class="reg_form" id="reg-ul">
                  <div id="userCue" class="cue">请佛主注意格式</div>
                  <li>  
                      <label for="user"  class="input-tips2">佛主名：</label>
                      <div class="inputOuter2">
                          <input type="text" id="user" name="user" maxlength="16" class="inputstyle2" placeholder="用户名位4-16字符" />
                      </div>         
                  </li>
                  <li>
                    <label for="passwd" class="input-tips2">佛主密码：</label>
                      <div class="inputOuter2">
                          <input type="password" id="passwd"  name="passwd" maxlength="16" class="inputstyle2" placeholder="密码不能小于6位" />
                      </div>   
                  </li>
                  <li>
                    <label for="passwd2" class="input-tips2">佛系确认：</label>
                      <div class="inputOuter2">
                          <input type="password" id="passwd2" name="passwd2" maxlength="16" class="inputstyle2" placeholder="再次确认密码" />
                      </div>
                    </li>
                    
                  <li style="display:none;">
                    <label for="qq" class="input-tips2">佛主QQ：</label>
                      <div class="inputOuter2">
                        <input type="text" value="946017153" id="qq" name="qq2" maxlength="10" class="inputstyle2"/>
                      </div>
                    </li>   
                  <li>
                      <div class="inputArea">
                          <input type="" id="reg" data-toggle="popover" title="弹出框" data-placement="bottom" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus." style="margin-top:10px;margin-left:85px;" class="button_blue" value="同意协议并注册" onclick="check_user()" /> 
                      </div>
                        
                  </li>
                  <div class="cl"></div>
                </ul>
            </form>
          </div>
        </div>
        <!--注册end-->
    </div>
  </div>
  <!--<button type="button" class="btn btn-lg btn-danger" data-toggle="popover" title="Popover title" data-content="And here's some amazing content. It's very engaging. Right?">点我弹出/隐藏弹出框</button>
  <script>
    $(function(){
      $('#reg').popover();
    })
  </script>-->
  <script>
    // function check_pass(){
    //   $.ajax({
    //     url: '/path/to/file',
    //     type: 'default GET (Other values: POST)',
    //     dataType: 'default: Intelligent Guess (Other values: xml, json, script, or html)',
    //     data: {param1: 'value1'},
    //   })
      
    // }

    function check_user(){
      if($('input[name=passwd]').val()!=$('input[name=passwd2]').val()){
        $('input[name=passwd2]').val('');
        $('input[name=passwd]').val('');
        // $('input[name=user]').val('');
        $.myToast('两次输入密码不一致,请重新输入!');
      }
      else{
        $.ajax({
          url: '/register',
          type: 'POST',
          dataType: 'json',
          data: {
            user: $('input[name=user]').val(),
            passwd2:$('input[name=passwd2]').val()
          },
          success:function(res){
            if(res==1){
              location.reload();
              $.myToast('注册成功!');
            }else if(res==0){
              $('input[name=user]').val('');
              $('input[name=passwd]').val('');
              $('input[name=passwd2]').val('');
              $.myToast('用户名已存在！');
            }
            
            console.log(res)
          }
        })
      }
    }
    function check_pass(){
      console.log(1)
      $.ajax({
        url: '/check_pass',
        type: 'post',
        dataType: 'json',
        data: {
          name:$('input[name=name]').val(),
          p:$('input[name=p]').val()
        },
        success:function(res){
          console.log(res)
          if(res==0){
            $.myToast('密码错误！');
          }else{
            location.href='/myHome'
            // $.myToast('登陆成功！');
          }
        }
      })
      
    }
  </script>
  </body>
</html>
